﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

    public class UserController : SystemAccountDataContext
    {
        private static UserController instance;
        public static UserController Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new UserController();
                }
                return instance;
            }
            set
            {
                instance = value;
            }
        }
        public bool InActive(int id)
        {
            SystemAccountDataContext dataContext = new SystemAccountDataContext();

            return false;
        }
        public List<User> GetUserList(string userName)
        {
            SystemAccountDataContext dataContext = new SystemAccountDataContext();
            return (from o in dataContext.Users
                    where (userName == null || o.UserName.Contains(userName))
                    orderby o.UserName descending
                    select o

                ).ToList();
        }
        public User GetUser(User condition)
        {
            SystemAccountDataContext dataContext = new SystemAccountDataContext();
            return (from o in dataContext.Users
                    where o.UserName == condition.UserName &&
                    o.UserPassword == condition.UserPassword &&
                    o.UserStatus == condition.UserStatus
                    select o).SingleOrDefault();
        }
    }